package com.qinhao.loveCrowdFunding.service;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qinhao.loveCrowdFunding.mapper.UserRegistryMapper;
import com.qinhao.loveCrowdFunding.pojo.NameContainBO;
import com.qinhao.loveCrowdFunding.pojo.NameContainDTO;
import com.qinhao.loveCrowdFunding.pojo.PhoneContainBO;
import com.qinhao.loveCrowdFunding.pojo.PhoneContainDTO;
import com.qinhao.loveCrowdFunding.pojo.UserRegistryDTO;
import com.qinhao.loveCrowdFunding.req.UserRegistryRequest;




@Service
public class UserRegistryService {
    @Autowired
    private UserRegistryMapper userRegistryMapper;

    private UserRegistryDTO userRegistryDTO = new UserRegistryDTO();
    public UserRegistryDTO insertUserByRegistry(UserRegistryRequest userRegistryRequest) {
       userRegistryMapper.insertUserByRegistry(userRegistryRequest);
       userRegistryMapper.insertUserIntergralByRegistry(userRegistryRequest);
        if (userRegistryRequest != null) {
            BeanUtils.copyProperties(userRegistryRequest, userRegistryDTO);
        }
        return userRegistryDTO;
    }

    public PhoneContainDTO queryPhone(UserRegistryRequest userRegistryRequest) {
       PhoneContainBO phoneContainBO = userRegistryMapper.queryPhone(userRegistryRequest);
       PhoneContainDTO phoneContainDTO = new PhoneContainDTO();
        if (phoneContainBO != null) {
           BeanUtils.copyProperties(phoneContainBO, phoneContainDTO);
       }
        return phoneContainDTO;
    }

    public NameContainDTO queryName(UserRegistryRequest userRegistryRequest) {
        NameContainBO nameContainBO = userRegistryMapper.queryName(userRegistryRequest);
        NameContainDTO nameContainDTO = new NameContainDTO();
        if (nameContainBO != null) {
            BeanUtils.copyProperties(nameContainBO, nameContainDTO);
        }
        return nameContainDTO;
    }
}
